package com.weiss.jpro.controller;

import com.weiss.jpro.dto.Result;
import com.weiss.jpro.service.IVoucherOrderService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 虎哥
 * @since 2021-12-22
 */
@RestController
@RequestMapping("/voucher-order")
public class VoucherOrderController {

    @Resource
    private IVoucherOrderService voucherOrderService;

    @PostMapping("seckill/{id}")
    public Result seckillVoucher(@PathVariable("id") Long voucherId) {
        // 优惠券秒杀下单功能：
        // 1.需要判断秒杀是否开始或者结束，如果尚未开始或已经结束则无法下单
        // 2.库存是否充足，不足则无法下单

        return voucherOrderService.seckillVoucher(voucherId);
    }
}